package com.ymatou.iapi.withdraw.testcase;

import static org.junit.Assert.assertFalse;
import static org.junit.Assume.assumeNotNull;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.ObjectUtils.Null;
import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.withdraw.parameter.PassApprovalBean;
import com.ymatou.iapi.withdraw.parameter.QueryWithDrawInvoiceBean;
import com.ymatou.iapi.withdraw.parameter.QueryWithDrawInvoiceResp;
import com.ymatou.iapi.withdraw.parameter.applyAlipayWithDrawForSellerBean;
import com.ymatou.iapi.withdraw.parameter.applyBankWithDrawForBuyerBean;
import com.ymatou.iapi.withdraw.parameter.applyBankWithDrawForSellerBean;
import com.ymatou.iapi.withdraw.parameter.applyXloboWithDrawForSellerBean;
import com.ymatou.iapi.withdraw.service.PassApprovalCall;
import com.ymatou.iapi.withdraw.service.QueryWithDrawInvoiceCall;
import com.ymatou.iapi.withdraw.service.applyAlipayWithDrawForSellerCall;
import com.ymatou.iapi.withdraw.service.applyBankWithDrawForBuyerCall;
import com.ymatou.iapi.withdraw.service.applyBankWithDrawForSellerCall;
import com.ymatou.iapi.withdraw.service.applyXloboWithDrawForSellerCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AccountCallServiceV2;
import com.ymttest.database.model.withdraw.Ymt_FundAccount;
import com.ymttest.database.model.withdraw.Ymt_FundAccountExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceApprovment;
import com.ymttest.database.model.withdraw.Ymt_InvoiceApprovmentExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceFundFlowLogExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceOperationLogExample;
import com.ymttest.database.model.withdraw.Ymt_InvoiceSerialSeedExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawCounter;
import com.ymttest.database.model.withdraw.Ymt_WithDrawCounterExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawIdempotentExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoice;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceEx;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceExExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceXloboLogExample;
import com.ymttest.database.model.withdraw.Ymt_WithDrawInvoiceExample.Criteria;
import com.ymttest.database.sqlwapper.WithdrawWapper;
import com.ymttest.utils.TestDataManager;

import oracle.net.aso.a;
/**
*审核查询列表--买家/买手/推手提现单审核
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryWithDrawInvoice{
	private static QueryWithDrawInvoiceBean bean;
	private static QueryWithDrawInvoiceCall call;
	Ymt_WithDrawInvoiceExample ymtinvoive=new Ymt_WithDrawInvoiceExample();//提现申请信息主表
	Ymt_InvoiceSerialSeedExample ymtserialseed=new Ymt_InvoiceSerialSeedExample();//单据编号种子表
	Ymt_WithDrawInvoiceXloboLogExample ymtxlobolog=new Ymt_WithDrawInvoiceXloboLogExample();//提现到贝海的日志
	Ymt_InvoiceFundFlowLogExample ymtflowlog=new Ymt_InvoiceFundFlowLogExample();//资金流转操作日志表
	Ymt_InvoiceOperationLogExample ymtoperationlog=new Ymt_InvoiceOperationLogExample();//单据操作日志表
	Ymt_WithDrawIdempotentExample ymtidempotent=new Ymt_WithDrawIdempotentExample();//提现申请幂等键记录表
	
	Ymt_WithDrawInvoiceExExample ymtinvoiveEx=new Ymt_WithDrawInvoiceExExample();//国内银行卡信息
	Ymt_InvoiceApprovmentExample ymtApprovement=new Ymt_InvoiceApprovmentExample();//单据审核记录表
	Ymt_WithDrawCounterExample ymtcounter=new Ymt_WithDrawCounterExample();//安利会提现计数
	
	applyBankWithDrawForBuyerBean bean2=new applyBankWithDrawForBuyerBean();
	applyBankWithDrawForBuyerCall call2=new applyBankWithDrawForBuyerCall();
	
	WithdrawWapper WithdrawWapper=new WithdrawWapper();
	
	private final int sellerid=3383;
	private final String sellerName="wesper";
	
	private final int userId=4085;
	private final String userName="lunchzhao";

	private final String fundAccountId_buyer="925CF663-FCBA-4380-846B-32162E58C317";
	private final String fundAccountName_buyer="吴文买家";
	private final String fundAccountNo_buyer="987654321789";
	
	private final String abroadFundAccountId="a0d8378e-af28-45bc-b211-5304d4869829";
	private final String abroadFundAccountName="wuwen";
	private final String abroadFundAccountNo="123456789123456";
	
	
	private final String fundAccountId_seller="925CF663-FCBA-4380-846B-32162E58C345";
	private final String fundAccountName_seller="吴文";
	private final String fundAccountNo_seller="123456789123";
	
	private final String alipayAccountNo_seller="18621614678";
	private final String alipayAccountName_seller="wuwenseller";
	private final String alipayAccountName_Id_seller="9d53eb3a-5867-4334-9735-269156eb7a26";
	
	private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("审核查询列表--买家/买手/推手提现单审核");
	}

	@Before
	public void caseUp() {
		bean=new QueryWithDrawInvoiceBean();
		call=new QueryWithDrawInvoiceCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	/**
	 * 买家提现到银行卡
	 * @return
	 * @throws Exception
	 */
	private String applyBanForBuyer() throws Exception {
		applyBankWithDrawForBuyerBean bean=new applyBankWithDrawForBuyerBean();
		applyBankWithDrawForBuyerCall call=new applyBankWithDrawForBuyerCall();
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(userId, 1);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999),
				new BigDecimal(0));
		//冻结资金
		BigDecimal freeze= WithdrawWapper.getSumFreezebyUserId(userId);
		Logger.comment("################冻结资金："+freeze);
		//查看账户余额
		BigDecimal balance=AccountCallServiceV2.getAccountBalance(userId, 1);
		Logger.comment("################账户余额："+balance);
		
		bean.setUserId(userId);
		bean.setWithDrawChannel(1);
		bean.setAccountTypeId(1);//提现帐户类型Id，默认值:1.人民币余额帐户
	    bean.setWithDrawAmount(new BigDecimal(1000));
	    bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到国际银行卡");
        bean.setApplyUserId(userId);
        bean.setApplyLoginId(userName);
        
        bean.setBankAccountName(fundAccountName_buyer);
        bean.setBankAccountNo(fundAccountNo_buyer);
        bean.setFundAccountId(fundAccountId_buyer);
	    bean.setCurrencyType(1);//1 人名币
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        
		call.setData(bean);
		call.callService();	
		return  call.getInvoiceId();
    }
	
	/**
	 * 买家提现到银行卡
	 * @return
	 * @throws Exception
	 */
	private String applyBanForBuyeranlihui() throws Exception {
		 //1:检查计数表Ymt_WithDrawCounter 一天一次是否已经计数
		//2:如果times=1 表示计数一次,不能再创建
		//3:修改计数times=0
		//4:删除当天的申请记录Ymt_WithDrawInvoice
		SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		LocalDateTime l=LocalDateTime.now();
		String begin=l.getYear()+"-"+l.getMonthValue()+"-"+l.getDayOfMonth()+" 00:00:00";
		ymtcounter.createCriteria().andCounterNameEqualTo("withdrawtimes").andTargetIdEqualTo("User"+userId+"_Type5")
		.andCycleTimeEqualTo(sf.parse(begin));
		
		List<Ymt_WithDrawCounter> counters=WithdrawWapper.selectYmtWithDrawCounter(ymtcounter);
		if(counters.size()==1)
		{
			Ymt_WithDrawCounter counter=counters.get(0);
			counter.setTimes(0);
			Map<String, Object> parameter=new HashMap<String, Object>();
			parameter.put("record", counter);
			parameter.put("example", ymtcounter);
			int updateCount=WithdrawWapper.updateCounterByExampleSelective(parameter);
			Logger.comment("### updateCount #### "+updateCount);
			
			ymtinvoive.createCriteria().andApplyTimeGreaterThanOrEqualTo(sf.parse(begin));
			int deletCount = WithdrawWapper.deleteByExample(ymtinvoive);
			Logger.comment("## deletCount # "+deletCount);
		}
		
		applyBankWithDrawForBuyerBean bean=new applyBankWithDrawForBuyerBean();
		applyBankWithDrawForBuyerCall call=new applyBankWithDrawForBuyerCall();
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(userId,5);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999),
				new BigDecimal(0));
		//冻结资金
		BigDecimal freeze= WithdrawWapper.getSumFreezebyUserId(userId);
		Logger.comment("################冻结资金："+freeze);
		//查看账户余额
		BigDecimal balance=AccountCallServiceV2.getAccountBalance(userId, 5);
		Logger.comment("################账户余额："+balance);
		
		bean.setUserId(userId);
		bean.setWithDrawChannel(1);
		bean.setAccountTypeId(5);//提现帐户类型Id，默认值:1.人民币余额帐户 5安利会
	    bean.setWithDrawAmount(new BigDecimal(10));
	    bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到国际银行卡");
        bean.setApplyUserId(userId);
        bean.setApplyLoginId(userName);
        
        bean.setBankAccountName(fundAccountName_buyer);
        bean.setBankAccountNo(fundAccountNo_buyer);
        bean.setFundAccountId(fundAccountId_buyer);
	    bean.setCurrencyType(1);//1 人名币
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        
		call.setData(bean);
		call.callService();	
		return  call.getInvoiceId();
    }
	/**
	 * 买手提现到银行卡
	 * @return
	 * @throws Exception
	 */
	private String applyBanForSeller() throws Exception {
		applyBankWithDrawForSellerBean bean=new applyBankWithDrawForSellerBean();
		applyBankWithDrawForSellerCall call=new applyBankWithDrawForSellerCall();
		
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(sellerid, 1);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999),
				new BigDecimal(0));
		//冻结资金
		BigDecimal freeze= WithdrawWapper.getSumFreezebyUserId(sellerid);
		Logger.comment("################冻结资金："+freeze);
		//查看账户余额
		BigDecimal balance=AccountCallServiceV2.getAccountBalance(sellerid, 1);
		Logger.comment("################账户余额："+balance);
		
		bean.setUserId(sellerid);
		bean.setWithDrawChannel(1);
		bean.setAccountTypeId(1);//提现帐户类型Id，默认值:1.人民币余额帐户
	    bean.setWithDrawAmount(new BigDecimal(1000));
	    bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到国内银行卡");
        bean.setApplyUserId(sellerid);
        bean.setApplyLoginId(sellerName);
        
        bean.setBankAccountName(fundAccountName_seller);
        bean.setBankAccountNo(fundAccountNo_seller);
        bean.setFundAccountId(fundAccountId_seller);
	    bean.setCurrencyType(1);//1 人名币
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        
		call.setData(bean);
		call.callService();		
		
		return  call.getInvoiceId();
    }
	/**
	 * 买手提现到银行卡-人名币To美元
	 * @return
	 * @throws Exception
	 */
	private String applyBankToUSDForSeller() throws Exception {
		applyBankWithDrawForSellerBean bean=new applyBankWithDrawForSellerBean();
		applyBankWithDrawForSellerCall call=new applyBankWithDrawForSellerCall();
		
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(sellerid, 1);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999999),
				new BigDecimal(0));
		//冻结资金
		BigDecimal freeze= WithdrawWapper.getSumFreezebyUserId(sellerid);
		Logger.comment("################冻结资金："+freeze);
		//查看账户余额
		BigDecimal balance=AccountCallServiceV2.getAccountBalance(sellerid, 1);
		Logger.comment("################账户余额："+balance);
		
		bean.setUserId(sellerid);
		bean.setWithDrawChannel(1);
		bean.setAccountTypeId(1);//提现帐户类型Id，默认值:1.人民币余额帐户
	    bean.setWithDrawAmount(new BigDecimal(6001));
	    bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到国际银行卡");
        bean.setApplyUserId(sellerid);
        bean.setApplyLoginId(sellerName);
        
        bean.setBankAccountName(abroadFundAccountName);
        bean.setBankAccountNo(abroadFundAccountNo);
        bean.setFundAccountId(abroadFundAccountId);
	    bean.setCurrencyType(4);//4 美元 	
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        
		call.setData(bean);
		call.callService();		
		
		return  call.getInvoiceId();
    }
	/**
	 * 买手提现到贝海
	 * @return
	 * @throws Exception
	 */
	private String applyXloboForSeller() throws Exception {
		applyXloboWithDrawForSellerBean bean=new  applyXloboWithDrawForSellerBean();
		applyXloboWithDrawForSellerCall call=new applyXloboWithDrawForSellerCall();
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(sellerid, 1);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999),
				new BigDecimal(0));
		
        bean.setSellerid(sellerid);
        bean.setAccountTypeId(1);//买手提现帐户类型:　1普通人民币账户 RmbAccount,15 拼邮溯源专项保证金,16 黑五专项保证金, 17 全球买手专项保证金,18 预售活动保证金,  19 直播保证金, 20 高客单价保证金中间帐户:　21 系统内部人民币账户
        bean.setWithDrawAmount(new BigDecimal(5));
        bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到贝海");
        bean.setApplyUserId(3383);
        bean.setApplyLoginId("wesper");
        bean.setXloboAccountNo("testaccount1");
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        
		call.setData(bean);
		call.callService();			
		
		return  call.getInvoiceId();
    }
	
	/**
	 * 买手提现到支付宝
	 * @return
	 * @throws Exception
	 */
	private String applyAlipayForSeller() throws Exception {
		applyAlipayWithDrawForSellerBean bean=new  applyAlipayWithDrawForSellerBean();
		applyAlipayWithDrawForSellerCall call=new applyAlipayWithDrawForSellerCall();
		//给帐号充值
		String accountid = AccountCallServiceV2.getAccountId(userId, 1);
		AccountCallServiceV2.resetAccount(accountid, new BigDecimal(999999),
				new BigDecimal(0));
		
        bean.setUserId(sellerid);
        bean.setUserType(1);//用户类型(0买家，１买手）
        bean.setAccountTypeId(1);//买手提现帐户类型:　1普通人民币账户 RmbAccount,15 拼邮溯源专项保证金,16 黑五专项保证金, 17 全球买手专项保证金,18 预售活动保证金,  19 直播保证金, 20 高客单价保证金中间帐户:　21 系统内部人民币账户
        bean.setWithDrawAmount(new BigDecimal(15));
        bean.setBusinessNo(new TestDataManager().getRandomNum(8));
        bean.setRemark("测试提现到支付宝");
        bean.setApplyUserId(sellerid);
        bean.setApplyLoginId(sellerName);
        bean.setAlipayAccountName(alipayAccountName_seller);
        bean.setAlipayAccountNo(alipayAccountNo_seller);
        bean.setFundAccountId(alipayAccountName_Id_seller);
        bean.setIdempotentNo(new TestDataManager().getRandomNum(8));
        bean.setWithDrawChannel(2);//1.买家PC 2.买手PC站 3.运营后台-资金 4.买家App 5.买手App 6.保证金提现 7.码头提现到贝海 8.专项保证金 9.b2b 10.推手APP
        
		call.setData(bean);
		call.callService();		
		
		return  call.getInvoiceId();
    }
	private void check_verify() throws InterruptedException
	{
		Criteria cinvoive= ymtinvoive.createCriteria();
		//1：根据条件查询申请表
		if(bean.getWithDrawInvoiceId()!=null)
			cinvoive.andWithDrawInvoiceIdEqualTo(bean.getWithDrawInvoiceId());
		if(bean.getAccountType()!=null)
			cinvoive.andUserAccountTypeEqualTo(bean.getAccountType());
		if(bean.getApproveStatus()!=null)
			cinvoive.andApproveStatusEqualTo(bean.getApproveStatus());
		if(bean.getIsPaidSuccess()!=null && bean.getIsPaidSuccess()==true)//InvoiceStatus (-1.失效，0.待处理，1.处理中，2. 处理失败，3.已完成)
			cinvoive.andInvoiceStatusEqualTo(3);
		else
			cinvoive.andInvoiceStatusNotEqualTo(3);
		if(bean.getApplyUserLoginId()!=null)
			cinvoive.andApplyUserLoginIdEqualTo(bean.getApplyUserLoginId());
		if(bean.getReceivableAccountType()!=null && bean.getReceivableAccountType().size()>0)
			cinvoive.andReceivableAccountTypeIn(bean.getReceivableAccountType());
		//if(bean.getSellerLevelList()!=null && bean.getSellerLevelList().size()>0)//sellerLevelList
			//
	    if(bean.getWithdrawAccountType()!=null)//withdrawAccountType
	    	cinvoive.andAccountTypeEqualTo(bean.getWithdrawAccountType());
		if(bean.getWithDrawType()!=null)
			cinvoive.andWithDrawTypeEqualTo(bean.getWithDrawType());
		if(bean.getStartTime()!=null)
			cinvoive.andCreateTimeGreaterThanOrEqualTo(bean.getStartTime());
		if(bean.getEndTime()!=null)
			cinvoive.andCreateTimeLessThanOrEqualTo(bean.getEndTime());
		if(bean.getBankAccountName()!=null)
			cinvoive.andBankAccountNameEqualTo(bean.getBankAccountName());
		if(bean.getFundAccountId()!=null)
			cinvoive.andFundAccountIdEqualTo(bean.getFundAccountId());
		if(bean.getHasHunter()==true)
			cinvoive.andWithDrawChannelEqualTo(10);
		else
			cinvoive.andWithDrawChannelNotEqualTo(10);
		
		ymtinvoive.setOrderByClause("CreateTime desc");
		ymtinvoive.getOrderByClause();
		
		List<Ymt_WithDrawInvoice> invoivelist = WithdrawWapper.selectYmtWithDrawInvoice(ymtinvoive);
		//2:循环获取银行帐号Id， 当前申请表对应的银行卡
		Logger.verifyEquals(invoivelist.size(),call.getRespon().getTotal(),"验证返回数据与查询的数据一致");
		
		for(int i=0;i<invoivelist.size();i++)
		{
		 if(i<=call.getRespon().getWithDrawInvoiceList().size()-1)
		 {
			Ymt_WithDrawInvoice invoice=invoivelist.get(i);
			Logger.comment("###### 1：Ymt_WithDrawInvoice 申请单据 #######");
			Logger.comment("#############  withDrawInvoiceId  ################ "+invoice.getWithDrawInvoiceId());
			QueryWithDrawInvoiceResp resp=call.getRespon().getWithDrawInvoiceList().get(i);
			Logger.verifyEquals(resp.getAccountType(), invoice.getAccountType(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的AccountType字段");
			Logger.verifyEquals(sdf.format(resp.getApplyTime()), sdf.format(invoice.getApplyTime()), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的ApplyTime字段");
			Logger.verifyEquals(resp.getApplyUserLoginId(), invoice.getApplyUserLoginId(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的applyUserLoginId字段");
			
			Logger.verifyEquals(resp.getApproveStatus(), invoice.getApproveStatus(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的approveStatus 字段");

			Logger.verifyEquals(resp.getBankAccountName(), invoice.getBankAccountName(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankAccountName字段");
			Logger.verifyEquals(resp.getBankAccountNo(), invoice.getBankAccountNo(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankAccountNo字段");
			Logger.verifyEquals(resp.getBankCity(), invoice.getBankCity(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankCity字段");
			Logger.verifyEquals(resp.getBankCountry(), invoice.getBankCountry(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankCountry字段");
			
			Logger.verifyEquals(resp.getBankHostCity(), invoice.getBankHostCity(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankHostCity字段");
			Logger.verifyEquals(resp.getBankName(), invoice.getBankName(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BankName字段");
			Logger.verifyEquals(resp.getBankState(), invoice.getBankState(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的bankState字段");
			Logger.verifyEquals(resp.getBranchAddress(), invoice.getBranchAddress(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BranchAddress字段");
			Logger.verifyEquals(resp.getBusinessName(), invoice.getBusinessName(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的BusinessName字段");
			//currencyRate
			
			Logger.verifyEquals(resp.getEmail(), invoice.getLoginEmail(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的LoginEmail字段");
			Logger.verifyEquals(resp.getFundAccountId(), invoice.getFundAccountId(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的fundAccountId字段");
			Logger.verifyEquals(resp.getIBanCode()==null?"":resp.getIBanCode(), invoice.getIBanCode(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的IBanCode字段");
			Logger.verifyEquals(resp.getInvoiceStatus(), invoice.getInvoiceStatus(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的InvoiceStatus字段");
			Logger.verifyEquals(resp.getPoundageAmount().stripTrailingZeros().toPlainString(), invoice.getPoundageAmount().stripTrailingZeros().toPlainString(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的PoundageAmount字段");
			Logger.verifyEquals(resp.getrReceivableAccountType(), invoice.getReceivableAccountType(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的receivableAccountType字段");
			Logger.verifyEquals(resp.getReceiverAddress(), invoice.getReceiverAddress(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的ReceiverAddress字段");
			
			Logger.verifyEquals(resp.getRemark(), invoice.getRemark(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的Remark字段");
			Logger.verifyEquals(resp.getRoutingNumber(), invoice.getRoutingNumber(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的routingNumber字段");
			Logger.verifyEquals(resp.getSwiftCode(), invoice.getSwiftCode(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的swiftCode字段");
			Logger.verifyEquals(resp.getThirdPartyPlatformAccount(), invoice.getThirdPartyPlatformAccount(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的ThirdPartyPlatformAccount字段");
			Logger.verifyEquals(sdf.format(resp.getUpdatTime()), sdf.format(invoice.getUpdateTime()), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的updatTime字段");
			Logger.verifyEquals(resp.getUserAccountType(), invoice.getUserAccountType(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的userAccountType字段");
			
			Logger.verifyEquals(resp.getUserid(), invoice.getUserId(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的UserId字段");
			Logger.verifyEquals(resp.getUserLoginId(), invoice.getUserLoginId(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的UserLoginId字段");
			Logger.verifyEquals(resp.getWithDrawAmount().stripTrailingZeros().toPlainString(), invoice.getWithDrawAmount().stripTrailingZeros().toPlainString(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的WithDrawAmount字段");
			Logger.verifyEquals(resp.getWithDrawInvoiceId(), invoice.getWithDrawInvoiceId(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的WithDrawInvoiceId字段");
			Logger.verifyEquals(resp.getWithDrawType(), invoice.getWithDrawType(), "验证"+(i+1)+"条 Ymt_WithDrawInvoice表中的WithDrawType字段");
			
			Logger.comment("###### 2：Ymt_InvoiceApprovment 单据审核记录表 #######");
			ymtApprovement.clear();
			ymtApprovement.createCriteria().andInvoiceIdEqualTo(invoice.getWithDrawInvoiceId());
			ymtApprovement.setOrderByClause(" CreateTime desc ");
			List<Ymt_InvoiceApprovment> approveLst=  WithdrawWapper.selectYmtInvoiceApprovment(ymtApprovement);
			if(approveLst.size()>0)
			{
				Ymt_InvoiceApprovment approve=approveLst.get(0);
				Logger.verifyEquals(resp.getApprovalResult(), approve.getApprovalResult(), "验证"+(i+1)+"条 Ymt_InvoiceApprovment表中的ApprovalResult字段");
			}else
			{
				Logger.verifyEquals(resp.getApprovalResult(), null, "验证"+(i+1)+"条 Ymt_InvoiceApprovment表中的ApprovalResult字段");
				Logger.comment("Ymt_InvoiceApprovment 表无记录数据");
			}
			
			Logger.comment("###### 3：Ymt_WithDrawInvoiceEx 导出 #######");
			ymtinvoiveEx.clear();
			ymtinvoiveEx.createCriteria().andWithDrawInvoiceIdEqualTo(invoice.getWithDrawInvoiceId());
			List<Ymt_WithDrawInvoiceEx> exLst= WithdrawWapper.selectYmtWithDrawInvoiceEx(ymtinvoiveEx);
			if(exLst.size()>0)
			{
				Ymt_WithDrawInvoiceEx ex=exLst.get(0);
				//BatchCode
				Logger.verifyEquals(resp.getBatchCode(), ex.getBatchCode(), "验证"+(i+1)+"条 Ymt_WithDrawInvoiceEx表中的BatchCode字段");
				//InputResultInfo
				Logger.verifyEquals(resp.getInputResultInfo(), ex.getInputResultInfo(), "验证"+(i+1)+"条 Ymt_WithDrawInvoiceEx表中的InputResultInfo字段");
			}
			else
			{
				Logger.comment("Ymt_WithDrawInvoiceEx 无记录数据");
				//BatchCode
				Logger.verifyEquals(resp.getBatchCode(),null, "验证"+(i+1)+"条 Ymt_WithDrawInvoiceEx表中的BatchCode字段");
				//InputResultInfo
				Logger.verifyEquals(resp.getInputResultInfo(), null, "验证"+(i+1)+"条 Ymt_WithDrawInvoiceEx表中的InputResultInfo字段");
		    }
		 }
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_001() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买家-银行");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForBuyer();
			bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(0);
			//bean.setApproveStatus(1);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(0);
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_002() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买手-银行");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForSeller();
			bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(1);
			bean.setApproveStatus(0);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
//			List<Integer> reTypeList=new ArrayList();
//			reTypeList.add(0);
//			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_003() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买手-贝海");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyXloboForSeller();
			bean.setWithDrawInvoiceId(invoiceId);
			//bean.setAccountType(1);
			//bean.setApproveStatus(0);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(2);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_004() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买手-支付宝");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyAlipayForSeller();
			bean.setWithDrawInvoiceId(invoiceId);
			//bean.setAccountType(1);
			//bean.setApproveStatus(0);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();				
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_005() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买手-提现人民币To美元");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBankToUSDForSeller();
			bean.setWithDrawInvoiceId(invoiceId);
			//bean.setAccountType(1);
			//bean.setApproveStatus(0);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
//			List<Integer> reTypeList=new ArrayList();
//			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
		//	bean.setReceivableAccountType(reTypeList);
			bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_005_1() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买家-银行-不传申请单据");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForBuyer();
			//bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(0);
			//bean.setApproveStatus(1);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(0);
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_006() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-三级审核");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForBuyer();
			PassApprovalBean pbean=new PassApprovalBean();
			PassApprovalCall pcall=new PassApprovalCall();
			//一级审核
			pbean.setInvoiceId(invoiceId);
			pbean.setApprovalLevel(1);
			pbean.setApprovalResult("一级审核通过_"+TestDataManager.random());
			pbean.setApprovalUserId(TestDataManager.getRandomIntNum(5));
			pbean.setApprovalUserLoginId("LoginId_"+TestDataManager.getRandomIntNum(5));
			pcall.setData(pbean);
			pcall.callService();	
			//二级审核
			pbean.setApprovalLevel(2);
			pbean.setApprovalResult("二级审核通过_"+TestDataManager.random());
			pbean.setApprovalUserId(TestDataManager.getRandomIntNum(5));
			pbean.setApprovalUserLoginId("LoginId_"+TestDataManager.getRandomIntNum(5));
			pcall.setData(pbean);
			pcall.callService();	
			//三级审核
			pbean.setApprovalLevel(3);
			pbean.setApprovalResult("三级审核通过_"+TestDataManager.random());
			pbean.setApprovalUserId(TestDataManager.getRandomIntNum(5));
			pbean.setApprovalUserLoginId("LoginId_"+TestDataManager.getRandomIntNum(5));
			pcall.setData(pbean);
			pcall.callService();	
			
			
			bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(0);
			//bean.setApproveStatus(1);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(0);
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_007() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-hasHunter为空");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForBuyer();
			bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(0);
			//bean.setApproveStatus(1);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(0);
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			//bean.setPageNo(0);
			//bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryWithDrawInvoice_008() {
		Logger.start(true,"正例-审核查询列表--买家/买手/推手提现单审核-买家-银行-安利会");
		try {
			String stime=LocalDateTime.now().plusDays(-1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			String etime=LocalDateTime.now().plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss:SSS"));
			
			String invoiceId=applyBanForBuyeranlihui();
			bean.setWithDrawInvoiceId(invoiceId);
			bean.setAccountType(0);
			bean.setWithdrawAccountType(5);
			//bean.setApproveStatus(1);
			//bean.setIsPaidSuccess(false);
			//bean.setApplyUserLoginId(userName);
			List<Integer> reTypeList=new ArrayList();
			reTypeList.add(0);
			reTypeList.add(1);
//			List<String> sellerLevelList=new ArrayList();
//			sellerLevelList.add("Top");
//			sellerLevelList.add("Pro");
//			sellerLevelList.add("Semi-Pro");
//			sellerLevelList.add("Warning List");
//			sellerLevelList.add("Active");
//			sellerLevelList.add("Inactive");
//			sellerLevelList.add("Newbie");
//			sellerLevelList.add("Black List");
			//bean.setReceivableAccountType(reTypeList);
			//bean.setWithDrawType(1);
			bean.setStartTime(sdf.parse(stime));
			bean.setEndTime(sdf.parse(etime));
			//bean.setBankAccountName(bankAccountName);
			//bean.setFundAccountId(fundAccountId);
			bean.setHasHunter(false);
			bean.setPageNo(1);
			bean.setPageSize(10);
			call.setData(bean);
			call.callService();			
			check_verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}
